home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / moustr.com / MOUSTRAP.PRN < prev    next >
Encoding:
Text File  |  1988-10-22  |  52.7 KB  |  2,167 lines

  1. P
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.                                                         The MouseTrap Library
  32.                                                High & Low Level Mouse Control
  33.                                                    Functions for 'C' Programs
  34.  
  35.                                                          Version 1.0
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.                                                           By James M. Curran.
  54.                                                             24 Greendale Road
  55.                                                               Cedar Grove, NJ
  56.                                                                    07009-1313
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.          G         Table of ContentsH
  65.  
  66.  
  67.  
  68.         1.   Introduction..................     3
  69.              Registration..................     3
  70.              Warranty......................     3
  71.  
  72.         2.   GBasic Mouse Control FunctionsH      4
  73.              Check_Mouse().................     5
  74.              Show_Mouse()..................     6
  75.              Hide_Mouse()..................     6
  76.              Get_Mouse_Position()..........     7
  77.              Set_Mouse_Position()..........     8
  78.              Get_Mouse_Press().............     9
  79.              Get_Mouse_Release()...........     9
  80.              Set_Mouse_Limit().............    10
  81.              Set_Mouse_Text_Cursor().......    11
  82.  
  83.         3.   GAdvanced Mouse Control FunctionsH  12
  84.              Activate_Mouse_Page()..........   13
  85.              Add_Mouse_Page()...............   14
  86.              Add_Mouse_Button().............   15
  87.              Add_Mouse_Hot_Spot()...........   16
  88.              Clear_All_Mouse_Definitions()..   17
  89.              Clear_Mouse_Pages()............   18
  90.              DeActivate_Mouse_Page()........   19
  91.              Define_Mouse_System()..........   20
  92.              Delete_Mouse_Page()............   21
  93.              Delete_Mouse_Button()..........   21
  94.              Delete_Mouse_Hot_Spot()........   21
  95.              Get_Char_Mouse_Kbd()...........   22
  96.              Read_Mouse()...................   23
  97.  
  98.         4.   GUsing the MouseTrap LibraryH       24
  99.  
  100.         5.   GTechnical SpecificationsH          29
  101.                 (only in registered versions)
  102.  
  103.         6.   GAppendixH                          30
  104.                 A. MOUSTRAP.H...............   31
  105.                 B. Global Variables.........   32
  106.                 C. Errors...................   33
  107.                 D. Reference................   34
  108.                 E. Support..................   35
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.                                      2
  118.  
  119.  
  120.  
  121.  
  122.  
  123.              GIntroductionH
  124.  
  125.              The  MouseTrap  library is a collection of  functions  to
  126.      control a mouse, designed to be called from a 'C' program.   They
  127.      provide  easy  access  to the low-level functions  of  the  mouse
  128.      interrupt,  as well as a simplified system for high-level control
  129.      over  the mouse.  The basic functions are mostly self explanatory
  130.      and  are described in chapter 2 of the document.   The high-level
  131.      functions  are  a  bit more complicated.  They are  described  in
  132.      Chapter 3 with a tutorial in Chapter 4.
  133.  
  134.  
  135.              GRegistrationH
  136.  
  137.           The  MouseTrap  Library is copyrighted by James  M.  Curran.
  138.      You  are  granted  a  limited  license  to  use  MouseTrap,   for
  139.      noncommercial programs.  You may, and are in fact encouraged,  to
  140.      copy  and distribute it,  provided that the following  conditions
  141.      are met:  (a)  No fee may be charged for copying or distributing,
  142.      and  (b)   only  the  library  files  (*.LIB)   and  accompanying
  143.      documentation   are  distributed,   and only in  their  original,
  144.      unmodified form.
  145.  
  146.           Sending a voluntary contribution of $15.00 will appease your
  147.      guilt, and earn you my undying gratitude.  It will also get you a
  148.      copy  of  the source code,  the  Compact  (CMOUSE.LIB)  &  Medium
  149.      (MMOUSE.LIB)  memory  model libraries,  the missing chapter  from
  150.      this booklet, and other assorted related files.   Microsoft C 5.1
  151.      &  MASM  5.1  are needed to recompile the source  files,  (unless
  152.      modified by the user).
  153.  
  154.           Contributions,  (and  requests for information on commercial
  155.      licenses) should be sent to :
  156.                               James M. Curran
  157.                               24 Greendale Road
  158.                               Cedar Grove, NJ 07009-1313
  159.  
  160.           Finally, there's only one thing you can say for sure about a
  161.      "Version  1.0"  release  of  software---  That it  will  soon  be
  162.      followed by a "Version 1.01" Bug-Fix release.  So, all registered
  163.      user  will be sent that version when it's ready.   (That's merely
  164.      cautionary; there are no known bugs at this time).
  165.  
  166.              GWarrantyH
  167.  
  168.           Warranty  ?   We make no promises that the MouseTrap library
  169.      will do anything useful for you.  Nor do we promise that it WON'T
  170.      do  anything  harmful.   (Life's  Tough;  "Want do you  want  for
  171.      nothing ? Rubber Biscuit ?")
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.                                      3
  179.  
  180.  
  181.  
  182.                                                             MouseTrap Library
  183.                                                            September 21, 1988
  184.  
  185.  
  186.  
  187.                     Chapter 2:
  188.  
  189.                          GBasic Mouse Control FunctionsH
  190.  
  191.  
  192.           The  eleven  primitives that make up the  low-level  support
  193.      functions  are almost direct calls to the mouse driver interrupt,
  194.      and are written in 8086 assembler.   They were originally derived
  195.      from  a  set  of 'C'  functions given in an article in  "The  'C'
  196.      Gazette"  (see  references  at  end),  but  since  then  numerous
  197.      revision  have  transformed them.   The only thing left  are  the
  198.      names of two functions.
  199.  
  200.           Check_Mouse()            Get_Mouse_Press()
  201.           Show_Mouse()             Get_Mouse_Release()
  202.           Hide_Mouse()             Set_Mouse_Text_Cursor()
  203.           Get_Mouse_Position()
  204.           Set_Mouse_Position()
  205.           Set_Mouse_Limits()
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.                                  - Page 4 -
  240.  
  241.  
  242.  
  243.                                                             MouseTrap Library
  244.                                                            September 21, 1988
  245.  
  246.           Check_Mouse - Check for the existence and type of a Mouse.
  247.  
  248.      GSyntax:H
  249.           #include <moustrap.h>
  250.  
  251.           mouse_t Check_Mouse(void);
  252.  
  253.      GDescription:H
  254.           This  function initialized the mouse interrupt  driver,  and
  255.      must   be   the   first  low-level  function  called   (but   see
  256.      Define_Mouse_System()).  It  check to  see if a mouse is attached
  257.      (or to be exact, if a mouse device driver is loaded into memory),
  258.      and if one is present, determines how many buttons it has.   This
  259.      information is return by the function,  and is also stored in the
  260.      global variable "_mouse_there".
  261.  
  262.      GReturns Value:H
  263.           If no mouse is detected, the Check_Mouse function returns 0.
  264.      If a mouse IS detected,  the number of buttons on it is returned.
  265.      These values are also stored in the global _mouse_there. This can
  266.      also be used as a TRUE/FALSE indicator.
  267.  
  268.      GSee Also:H
  269.           Define_Mouse_System, _mouse_there
  270.  
  271.      GExample:H
  272.        #include <moustrap.h>
  273.        #include <stdio.h>
  274.        main()
  275.        {
  276.          Check_Mouse();
  277.          if (_mouse_there)
  278.              printf("A %d-button Mouse was detected.\n",_mouse_there);
  279.           else
  280.              printf("No mouse was found.\n");
  281.         }
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.                                  - Page 5 -
  301.  
  302.  
  303.  
  304.                                                             MouseTrap Library
  305.                                                            September 21, 1988
  306.  
  307.           Show_Mouse - Display Mouse Cursor.
  308.           Hide_Mouse - Hide Mouse Cursor.
  309.  
  310.      GSyntax:H
  311.           #include <moustrap.h>
  312.  
  313.           void Show_Mouse(void);
  314.           void Hide_Mouse(void);
  315.  
  316.      GDescription:H
  317.      GH     Show_Mouse  causes  the mouse cursor to be displayed on  the
  318.      screen. Hide_Mouse cause the mouse cursor to disappear.   Neither
  319.      will  have any effect if there is no mouse or Check_Mouse has not
  320.      been executed yet.
  321. GH
  322.      GReturns Value:H
  323.           There is no return value.
  324.  
  325.      GSee Also:H
  326.           Check_Mouse, _mouse_there
  327.  
  328.      GExample:H
  329.        #include <moustrap.h>
  330.        #include <stdio.h>
  331.        main()
  332.        {
  333.          Check_Mouse();
  334.  
  335.  
  336.  
  337.         }
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.                                  - Page 6 -
  362.  
  363.  
  364.  
  365.                                                             MouseTrap Library
  366.                                                            September 21, 1988
  367.  
  368.  
  369.              Get_Mouse_Position
  370.  
  371.      GSyntax:H
  372.              #include <moustrap.h>
  373.              mouse_t Get_Mouse_Position(mouse_t *X, mouse_t *Y);
  374.  
  375.      GDescription:H
  376.              Get_Mouse_Position   places   the  X  (Horizontal)   and   Y
  377.      (Vertical)  coordinates  of the present location of the mouse cursor
  378.      into  the locations given by X &  Y.   The locations are given using
  379.      graphic  coordinates in the range (0,0)  to (639,199).It also return
  380.      the  binary sum of the buttons pressed.   If _mouse_there  indicates
  381.      that no mouse was detected, the values of X &  Y are left unchanged,
  382.      and the function returns 0.
  383.  
  384.      GReturn Value:H
  385.              The binary sum of the buttons pressed, where the Left button
  386.      equals  1,  the  Right button equals 2,  and the Middle  button,  4.
  387.      These  value are added together if more than one button is  pressed.
  388.      For  example,  pressing  the  Left  &   Middle  buttons  would  have
  389.      Get_Mouse_Position return a value of 5.
  390.  
  391.      GSee Also:H
  392.              _mouse_there, Set_Mouse_Position
  393.  
  394.      GExample:H
  395.              #include <moustrap.h>
  396.              #include <stdio.h>
  397.              main()
  398.              {
  399.                      int     X,Y,m;
  400.  
  401.                      Check_Mouse();
  402.                      do {
  403.                              m = Get_Mouse_Position( &X, &Y);
  404.                              if (m & 1)
  405.                                      printf("Left Button, ");
  406.  
  407.                              if (m & 2)
  408.                                      printf("Right Button, ");
  409.  
  410.                              if (m & 4)
  411.                                      printf("Middle Button, ");
  412.  
  413.                              if (m)
  414.                                      printf("pressed at (%d, %d)\n",X,Y);
  415.  
  416.                         } while (m==0);
  417.              }
  418.              Pressing the Left & Right buttons would print something
  419.      similar to:
  420.              GLeft Button, Right Button pressed at (120, 85)H
  421.  
  422.                                  - Page 7 -
  423.  
  424.  
  425.  
  426.                                                             MouseTrap Library
  427.                                                            September 21, 1988
  428.  
  429.      GH        Set_Mouse_Position
  430.  
  431.      GSyntax:H
  432.              #include <moustrap.h>
  433.  
  434.              void Set_Mouse_Position(mouse_t X, mouse_t Y);
  435.  
  436.  
  437.      GDescription:H
  438.  
  439.              The  function  Set_Mouse_Position moves the mouse cursor  to
  440.      the  screen location given by the graphic coordinates (X,Y).  X must
  441.      be in the range (0-639) and Y in the range (0-199).
  442.  
  443.      GReturn Value:H
  444.  
  445.              None.
  446.  
  447.  
  448.      GSee Also:H
  449.      GH        Get_Mouse_Position
  450.  
  451.  
  452.      GExample:H
  453.              #include <moustrap.h>
  454.              #include <stdio.h>
  455.  
  456.              main()
  457.              {
  458.                      int     X,Y,m;
  459.  
  460.                      Check_Mouse();
  461.  
  462.                      Show_Mouse();
  463.  
  464.                      Get_Mouse_Position( &X, &Y);
  465.  
  466.                      X++;
  467.                      Y--;
  468.  
  469.                      Set_Mouse_Position(  X,  Y);
  470.  
  471.              }
  472.  
  473.              The above program would move the mouse cursor, "Up" and to
  474.      the "Right", without the mouse physically being moved.
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.                                  - Page 8 -
  484.  
  485.  
  486.  
  487.                                                             MouseTrap Library
  488.                                                            September 21, 1988
  489.  
  490.              Get_Mouse_Press
  491.              Get_Mouse_Release
  492.  
  493.      GSyntax:H
  494.              mouse_t Get_Mouse_Press(mouse_t Button, mouse_t Status,
  495.                                      mouse_t *X,     mouse_t *Y);
  496.  
  497.              mouse_t Get_Mouse_Release(mouse_t Button, mouse_t Status,
  498.                                      mouse_t *X,     mouse_t *Y);
  499.  
  500.  
  501.      GDescription:H
  502.              Get_Mouse_Press  returns information about the last press of
  503.      one  of  the  mouse  buttons,  given  by  the  code  "Button".   The
  504.      coordinates  of the location of the mouse cursor the last time  that
  505.      button  was  pressed are returned in X &  Y.   The  Function  itself
  506.      returns  the number of times that button was pressed since the  last
  507.      time  Get_Mouse_Press  was  called.  The binary sum of  the  buttons
  508.      currently pressed,  as described in Get_Mouse_Position,  is returned
  509.      in Status.
  510.  
  511.              Get_Mouse_Release  works exactly the same way,  with X and Y
  512.      giving the location of the last position the button was released.
  513.  
  514.      GReturn Value:H
  515. GH
  516.              The  number of time Button was pressed (released)  since the
  517.      last call to Get_Mouse_Press (Get_Mouse_Release).
  518.  
  519.      GSee Also:H
  520.  
  521.              Get_Mouse_Position
  522.  
  523.      GExample:H
  524.  
  525.              #include <moustrap.h>
  526.              #include <stdio.h>
  527.  
  528.              main()
  529.              {
  530.                mouse_t s,x,y;
  531.                if (Check_Mouse()) {
  532.                    getch()         /* pause of while */
  533.                    if (Get_Mouse_Press(M_Left,&s,&x,&y))
  534.                       printf("Left buttom was pressed at %d,%d\n", x,y);
  535.                    }
  536.              }
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.                                  - Page 9 -
  545.  
  546.  
  547.  
  548.                                                             MouseTrap Library
  549.                                                            September 21, 1988
  550.  
  551.              Set_Mouse_Limit
  552.  
  553.      GSyntax:H
  554.              void    Get_Mouse_Press(Direction, Min, Max);
  555.              mouse_t Direction;       /* M_HORIZ -or- M_VERT */
  556.              mouse_t Min;
  557.              mouse_t Max;
  558.  
  559.      GDescription:H
  560.              Forces  the  mouse cursor's movements to remain  within  the
  561.      limits specificed.   Min and Max are given using graphic coordinates
  562.      (0-629)  (0-199),  and  it requires two calls to limit motion in all
  563.      directions.
  564.  
  565.      GReturn Value:H
  566.      GH        None
  567. GH
  568.      GSee Also:H
  569.  
  570.  
  571.      GExample:H
  572.  
  573.              #include <moustrap.h>
  574.              #include <stdio.h>
  575.  
  576.              main()
  577.              {
  578.                      Check_Mouse();
  579.                      Set_Mouse_Limit(M_VERT,49,149);
  580.                      Set_Mouse_Limit(M_HORIZ,159,479);
  581.              /* Mouse is now limited to the center of the screen */
  582.                      Read_Mouse();
  583.              }
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.                                 - Page 10 -
  606.  
  607.  
  608.  
  609.                                                             MouseTrap Library
  610.                                                            September 21, 1988
  611.  
  612.              Set_Mouse_Text_Cursor
  613.  
  614.      GSyntax:H
  615.              void    Set_Mouse_Text_Cursor(Type, P1, P2);
  616.  
  617.              mouse_t Type;           /* 1 = Hardware Cursor */
  618.              mouse_t P1              /* Start scan line     */
  619.              mouse_t P2;             /* Stop  scan line     */
  620.                -or-
  621.              mouse_t Type;           /* 0 = Software Cursor */
  622.              mouse_t P1;             /* Screen Mask         */
  623.              mouse_t P2;             /* Cursor Mask         */
  624.  
  625.      GDescription:H
  626.              Set_Mouse_Text_Cursor  describes  how the mouse cursor  will
  627.      appear  on the screen.   This can be done in either of two  way:  by
  628.      using  the Hardware cursor,  or the Software cursor.   The  Hardware
  629.      cursor  is  the same one that the keyboard uses.   If  the  hardware
  630.      cursor is used,  P1 &  P2 give the scan lines for that cursor.   For
  631.      normal screen uses that 6 & 7.  The Software cursor is a little more
  632.      complex.   There,  P1  is  the "Screen mask"  and P2 is the  "Cursor
  633.      Mask".  When  the  software  cursor  is drawn  on  the  screen,  the
  634.      character  and color attribute is first ANDed with the screen  mask,
  635.      then  the  result  of that is XORed with the cursor  mask.   If  the
  636.      screen  mask is 0,  the net effect is that the current value at that
  637.      location  is  replaced by the cursor mask.   If the screen  mask  is
  638.      nonzero,  the  current  value at the screen location WILL effect  of
  639.      character or color of the mouse cursor.
  640. GH
  641.      GReturn Value:H
  642.      GH        None.
  643.  
  644.      GExample:H
  645.  
  646.              See Chapter 4.
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.                                 - Page 11 -
  667.  
  668.  
  669.  
  670.                                                             MouseTrap Library
  671.                                                            September 21, 1988
  672.  
  673.  
  674.  
  675.                      Chapter 3
  676.      G                        Advanced Mouse Control FunctionsH
  677.  
  678.              These   thirteen   functions   simplify   the   process   of
  679.      interpreting  the  users  input  using a mouse.  They  work  on  the
  680.      assumption  that  most of the time a mouse is used by  "clicking"  a
  681.      specific  button  at  a specific place on  the  screen.   They  were
  682.      written using Microsoft's C v5.1.
  683.  
  684.  
  685.              Activate_Mouse_Page()
  686.              Add_Mouse_Button()
  687.              Add_Mouse_Hot_Spot()
  688.              Add_Mouse_Page()
  689.              Clear_All_Mouse_Definition()
  690.              Clear_Mouse_Pages()
  691.              DeActivate_Mouse_Page()
  692.              Define_Mouse_System()
  693.              Delete_Mouse_Button()
  694.              Delete_Mouse_Hot_Spot()
  695.              Delete_Mouse_Page()
  696.              Get_Char_Mouse_Kbd()
  697.              Read_Mouse()
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.                                 - Page 12 -
  728.  
  729.  
  730.  
  731.                                                             MouseTrap Library
  732.                                                            September 21, 1988
  733.  
  734.              Activate_Mouse_Page
  735. GH
  736.      GSyntax:H
  737.              #include <moustrap.h>
  738.              mouse_t Activate_Mouse_Page(mouse_t Page_ID)
  739.  
  740.      GDescription:H
  741.              The  Activate_Mouse_Page  function  sets active one  of  the
  742.      previously defined mouse pages.  In Single Page mode,  the currently
  743.      active page is cleared,  and the mouse cursor is limited to the area
  744.      of that page. In Overlaid mode, the current pages remain active, and
  745.      the mouse cursor area is widened,  if necessary,  to accommodate the
  746.      new page.
  747. GH
  748.      GReturn Value:H
  749.              MNOERROR if there was no problem, otherwise
  750.              MERROR with M_Error set to the specific error.
  751. GH
  752.      GSee Also:H
  753.              M_Error, DeActivate_Mouse_Page, Add_Mouse_Page
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.                                 - Page 13 -
  789.  
  790.  
  791.  
  792.                                                             MouseTrap Library
  793.                                                            September 21, 1988
  794.  
  795.                      Add_Mouse_Page
  796.      GSyntax:H
  797.              #include <moustrap.h>
  798.  
  799.              mouse_t Add_Mouse_Page(Page_Type, Top, Left, Bottom, Right);
  800.  
  801.              mouse_t         Page_Type;      /* M_Text_Coord    or  */
  802.                                              /* M_Graphic_Coord     */
  803.              Mouse_t         Top;
  804.              mouse_t         Left;           /* Coordinates of corners */
  805.              mouse_t         Bottom;         /* of the page.           */
  806.              mouse_t         Right;
  807.  
  808.      GDescription:H
  809.              Defines  a  new  mouse page which is added  to  the  system.
  810.      Page_Type   tells  if  the  corner  points  are  given  using   text
  811.      coordinates (80x25)  or Graphic coordinates (640x200).   Coordinates
  812.      of  Hot Spots for this page are also assumed to be given using  that
  813.      system.
  814.  
  815.      GReturn Value:H
  816.              Return  a Page ID number,  which is to be used to  reference
  817.      this  page in the future,  or,  MERROR if there was a problem,  with
  818.      it's cause given in M_Error.
  819. GH
  820.      GSee Also:H
  821.              Delete_Mouse_Page, Add_Mouse_Button, Add_Mouse_Hot_Spot
  822.              M_Error, Activate_Mouse_Page, DeActivate_Mouse_Page
  823.      GExample:H
  824.  
  825.              See Chapter 4.
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.                                 - Page 14 -
  850.  
  851.  
  852.  
  853.                                                             MouseTrap Library
  854.                                                            September 21, 1988
  855.  
  856.                      Add_Mouse_Button
  857.      GSyntax:H
  858.              #include <moustrap.h>
  859.  
  860.              mouse_t Add_Mouse_Button(Page_ID, Button, Return_Value);
  861.              mouse_t Page_ID;
  862.              mouse_t Button;
  863.              mouse_t Return_Value;
  864. GH
  865.      GDescription:H
  866.              Add_Mouse_Button  lets you tell the system how to react to a
  867.      certain  button  being  pressed.   Page_ID is the  page  which  this
  868.      definition refers to, or if 0, the definition is valid in all pages.
  869.      Button is either M_Left, M_Right, or M_Center.   If the Return_Value
  870.      is 0,  it's assumed the Hot Spots are associated with this button in
  871.      this page. Otherwise,  the Return_Value is any value the user wished
  872.      to assign.  It's return by Read_Mouse and Get_Char_Mouse_Kbd if that
  873.      button is pressed while that page is active.   In Overlaid mode,  if
  874.      more  than one page,  with conflicting definitions,  are active  the
  875.      most  recent Add_Mouse_Button has precedence.   Any definition of  a
  876.      particular  Page/Button combination replaces any previous definition
  877.      of that combination.
  878.  
  879.      GReturn Value:H
  880.              MNOERROR if there was no problem; otherwise
  881.              MERROR with the specific error given in M_Error
  882. GH
  883.      GSee Also:H
  884.              M_Error, Add_Mouse_Page, Add_Mouse_Hot_Spot
  885. GH
  886.      GExample:H
  887.              See Chapter 4.
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.                                 - Page 15 -
  911.  
  912.  
  913.  
  914.                                                             MouseTrap Library
  915.                                                            September 21, 1988
  916.  
  917.  
  918.                      Add_Mouse_Hot_Spot
  919.      GSyntax:H
  920.              #include <moustrap.h>
  921.  
  922.              mouse_t Add_Mouse_Hot_Spot(Page_ID, Button, Top, Left,
  923.                                         Bottom, Right, Return_Value);
  924.              mouse_t Page_ID;
  925.              mouse_t Button;
  926.              mouse_t Top;            /* corner of the area */
  927.              mouse_t Left;
  928.              mouse_t Bottom;
  929.              mouse_t Right;
  930.              mouse_t Return_Value;
  931.  
  932.      GDescription:H
  933.              Add_Mouse_Hot_Spot   defines  an  area  such  that  if   the
  934.      appropriate  Button is pressed while the mouse cursor is within  the
  935.      area  given  while the page given by Page_ID is  active,  Read_Mouse
  936.      will  return  Return_Value.   A  maximum of 65535 hot spots  can  be
  937.      defined.
  938.  
  939.      GReturn Value:H
  940.              An  ID  number for this hot spot,  if there was no  problem;
  941.      otherwise MERROR with the specific error given in M_Error.
  942.  
  943.      GSee Also:H
  944.              M_Error, Delete_Mouse_Hot_Spot
  945.  
  946.      GExample:H
  947.              See Chapter 4.
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.                                 - Page 16 -
  972.  
  973.  
  974.  
  975.                                                             MouseTrap Library
  976.                                                            September 21, 1988
  977.  
  978.                      Clear_All_Mouse_Definitions
  979.      GSyntax:H
  980.              #include <moustrap.h>
  981.  
  982.              mouse_t Clear_All_Mouse_Definitions(void);
  983. GH
  984.      GDescription:H
  985.              Erases everything.  Removes all Page,  Button,  and Hot Spot
  986.      definitions. Reset various internal variables.   Must be done before
  987.      switching between Single Page & Overlaid modes.
  988.  
  989.      GReturn Value:H
  990.              MNOERROR if there was no problem; otherwise
  991.              MERROR with the specific error given in M_Error
  992.  
  993.      GSee Also:H
  994.              M_Error, Define_Mouse_System
  995.  
  996.      GExample:H
  997.              See Chapter 4.
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.                                 - Page 17 -
  1033.  
  1034.  
  1035.  
  1036.                                                             MouseTrap Library
  1037.                                                            September 21, 1988
  1038.  
  1039.                   Clear_Mouse_Pages
  1040.      GSyntax:H
  1041.              #include <moustrap.h>
  1042.  
  1043.              mouse_t Clear_Mouse_Pages(void);
  1044.  
  1045.      GDescription:H
  1046.              Deactivates  all mouse pages.  Hides cursors.  Resets cursor
  1047.      limits.
  1048.  
  1049.      GReturn Value:H
  1050.              MNOERROR if there was no problem; otherwise
  1051.              MERROR with the specific error given in M_Error
  1052.  
  1053.      GSee Also:H
  1054.              M_Error, DeActivate_Mouse_Page, Activate_Mouse_Cursor
  1055.  
  1056.      GExample:H
  1057.              See Chapter 4.
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.                                 - Page 18 -
  1094.  
  1095.  
  1096.  
  1097.                                                             MouseTrap Library
  1098.                                                            September 21, 1988
  1099.  
  1100.                      DeActivate_Mouse_Page
  1101.      GSyntax:H
  1102.              #include <moustrap.h>
  1103.  
  1104.              mouse_t DeActivate_Mouse_Page(Page_ID);
  1105.              mouse_t Page_ID;
  1106. GH
  1107.      GDescription:H
  1108.              Deactivates  the referenced mouse page.  Button and Hot Spot
  1109.      definitions  linked  to  that  page will no  longer  function  until
  1110.      restarted  with Activate_Mouse_Page.   On Single page mode,  this is
  1111.      done automatically when another page is activated.
  1112.  
  1113.      GReturn Value:H
  1114.              MNOERROR if there was no problem; otherwise
  1115.              MERROR with the specific error given in M_Error
  1116.  
  1117.      GSee Also:H
  1118.              M_Error  Activate_Mouse_Page, Clear_Mouse_Pages
  1119.  
  1120.      GExample:H
  1121.              See Chapter 4.
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.                                 - Page 19 -
  1155.  
  1156.  
  1157.  
  1158.                                                             MouseTrap Library
  1159.                                                            September 21, 1988
  1160.  
  1161.                      Define_Mouse_System
  1162.      GSyntax:H
  1163.              #include <moustrap.h>
  1164.  
  1165.              mouse_t Define_Mouse_System(Page_Type);
  1166.              mouse_t Page_type;
  1167.  
  1168.      GDescription:H
  1169.              Define_Mouse_System  declares how mouse pages are to be used
  1170.      through  the program.   Page_Type must be either M_Overlaid_Pages or
  1171.      M_Single_Pages.   Automatically   initializes  mouse  by   executing
  1172.      Check_Mouse.   Can  only be done once in a program unless reset with
  1173.      Clear_All_Mouse_Definitions.
  1174.  
  1175.      GReturn Value:H
  1176.              MNOERROR if there was no problem; otherwise
  1177.              MERROR with the specific error given in M_Error
  1178. GH
  1179. GH
  1180.      GSee Also:H
  1181.              M_Error, Clear_All_Mouse_Definitions, Check_Mouse
  1182.  
  1183.      GExample:H
  1184.              See Chapter 4.
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.  
  1196.  
  1197.  
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.                                 - Page 20 -
  1216.  
  1217.  
  1218.  
  1219.                                                             MouseTrap Library
  1220.                                                            September 21, 1988
  1221.  
  1222.                      Delete_Mouse_Button
  1223.                      Delete_Mouse_Hot_Spot
  1224.                      Delete_Mouse_Page
  1225.      GSyntax:H
  1226.            #include <moustrap.h>
  1227.  
  1228.            mouse_t Delete_Mouse_Button(mouse_t Page_ID, mouse_t Button);
  1229.            mouse_t Delete_Mouse_Hot_Spot(mouse_t HS_ID);
  1230.            mouse_t Delete_Mouse_Page(mouse_t Page_ID);
  1231.  
  1232.      GDescription:H
  1233.              Removes the indicated item from the system.
  1234.  
  1235.      GReturn Value:H
  1236.              MNOERROR if there was no problem; otherwise
  1237.              MERROR with the specific error given in M_Error
  1238. GH
  1239. GH
  1240.      GSee Also:H
  1241.              M_Error
  1242.  
  1243.      GExample:H
  1244.              See Chapter 4.
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.                                 - Page 21 -
  1277.  
  1278.  
  1279.  
  1280.                                                             MouseTrap Library
  1281.                                                            September 21, 1988
  1282.  
  1283.                      Get_Char_Mouse_Kbd
  1284.      GSyntax:H
  1285.              #include <moustrap.h>
  1286.  
  1287.              mouse_t Get_Char_Mouse_Kbd(void);
  1288.  
  1289.      GDescription:H
  1290.              Get_Char_Mouse_Kbd  acts  much  like  the  standard  library
  1291.      function  GETCH,  but will accept input from either the keyboard  or
  1292.      the  mouse.   Will return only when some input is received from  the
  1293.      keyboard or mouse.
  1294. GH
  1295.      GReturn Value:H
  1296.              The value inputted if there was no problem; otherwise
  1297.              MERROR with the specific error given in M_Error
  1298. GH
  1299. GH
  1300.      GSee Also:H
  1301.              M_Error, Read_Mouse
  1302.  
  1303.      GExample:H
  1304.              See Chapter 4.
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.  
  1328.  
  1329.  
  1330.  
  1331.  
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.                                 - Page 22 -
  1338.  
  1339.  
  1340.  
  1341.                                                             MouseTrap Library
  1342.                                                            September 21, 1988
  1343.  
  1344.  
  1345.                      Read_Mouse
  1346.      GSyntax:H
  1347.              #include <moustrap.h>
  1348.  
  1349.              mouse_t Read_Mouse(void)
  1350. GH
  1351.      GDescription:H
  1352.              Checks mouse for input.
  1353.  
  1354.      GReturn Value:H
  1355.              the  Return_value assigned to a Button or Hot Spot,  if that
  1356.      item was "clicked" on, or
  1357.              0 if no button was pressed.
  1358.  
  1359.      GSee Also:H
  1360.              M_Error, Get_Char_Mouse_Kbd
  1361.  
  1362.      GExample:H
  1363.              See Chapter 4.
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.                                 - Page 23 -
  1399.  
  1400.  
  1401.  
  1402.                                                             MouseTrap Library
  1403.                                                            September 21, 1988
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.              Chapter 4
  1410.  
  1411.  
  1412.  
  1413.      G                        Using the MouseTrap LibraryH
  1414.  
  1415.  
  1416.  
  1417.  
  1418.              The  basic concept of the MouseTrap is the "Mouse  Page".  A
  1419.      Mouse  Page is one set of button and "Hot  spot"  definitions.   Any
  1420.      character  can  be assigned to a button or hot spot.   Pages can  be
  1421.      used in either of two ways:  You can have up ot 65,000 single pages,
  1422.      which  can only be used one at a time,  or up to 16 page  "overlaid"
  1423.      pages,  any combination of which can be active at once.   You choose
  1424.      this   by  using  the  Define_Mouse_System  function,   with  either
  1425.      M_Single_Pages or M_Overlaid_Pages.
  1426.  
  1427.              The   next  step  is  to  define  a  page,   by  using   the
  1428.      Add_Mouse_Page  function,  passing to it the "type"  of page it  is,
  1429.      either M_Graphic_Coord or M_Text_Coord;  and the 4 corner points for
  1430.      that  page using the appropriate set of coordinates (either 80x25 or
  1431.      640x200).   Using "0"  for each corner will have it using the entire
  1432.      screen.  Add_Mouse_Page will return a ID number for the page,  which
  1433.      you will be using in all future references to this page.
  1434.  
  1435.              Next,  you must define the buttons you will be using.   This
  1436.      is done with Add_Mouse_Button.  You tell it which for which page and
  1437.      button this definition is to apply,  and the value to return if that
  1438.      button was clicked while that page was active.   If you use "0"  for
  1439.      the  Page ID,  this definition will apply to all pages.   If you use
  1440.      "0" for the return value,  you can have that button return different
  1441.      values for being clicked at different "hot spots" within the page.
  1442.  
  1443.              If  you  are using hot spots in a page,  you must next  call
  1444.      Add_Mouse_Hot_Spot,  passing to it the page ID and button code,  the
  1445.      corner points, and the return value for the spot.
  1446.  
  1447.              Now,  we  get  to  the fun part.   Choose a page  using  the
  1448.      Activate_Mouse_Page  function.  Using  overlaid page,  you can  have
  1449.      several    pages   active   at   once;    remove   them   with   the
  1450.      DeActivate_Mouse_Page or Clear_Mouse_Pages function.  In single page
  1451.      mode, activating a new page automatically deactivates the last one.
  1452.  
  1453.              Finally,  simply  call Read_Mouse().   It will return either
  1454.      the  value for the button or Hot spot clicked or 0 if no button  was
  1455.      clicked.   Or simpler still,  use Get_Char_Mouse_Kbd(),  which waits
  1456.      until some input is entered by either keyboard or mouse.
  1457.  
  1458.  
  1459.                                 - Page 24 -
  1460.  
  1461.  
  1462.  
  1463.                                                             MouseTrap Library
  1464.                                                            September 21, 1988
  1465.  
  1466.              To  further  exemplify the process let's examine the  sample
  1467.      program MICETEST.C:
  1468.  
  1469.      #include <stdio.h>
  1470.      #include "moustrap.h"
  1471.  
  1472.      #include <graph.h>
  1473.  
  1474.      main ()
  1475.      {
  1476.              mouse_t y,z,c;
  1477.  
  1478.       The  data type "mouse_t"  is defined in MOUSTRAP.H.   All variables
  1479.      used with the MouseTrap library should be define as this type.
  1480.  
  1481.      The  first  group  of  lines  setup the screen  so  it's  easier  to
  1482.      understand what's happening with the mouse.   But by themselves they
  1483.      do  nothing  of interest to this discussion.   Ignore them and  skip
  1484.      down a bit.
  1485.  
  1486.  
  1487.              Define_Mouse_System(M_Single_Pages);
  1488.  
  1489.      For the first step,  we going to be using single pages;  only one of
  1490.      the pages we're about the define can be active at only given time.
  1491.  
  1492.              y=Add_Mouse_Page(M_Text_Coord,15,20,24,40);
  1493.  
  1494.              z=Add_Mouse_Page(M_Text_Coord,5,10,15,20);
  1495.  
  1496.      Next,  we  define  two mouse pages,  Y &  Z.   Y is limited  to  the
  1497.      rectangle from row 15, column 20 to row 24, column 40. Similarly,  Z
  1498.      is the area from (5,10) to (15,20).
  1499.  
  1500.              Set_Mouse_Text_Cursor(0,0,TC(' ',4,4));
  1501.  
  1502.      Now,  we  describe how we the mouse cursor to look.   We start  with
  1503.      something simple.  We'll use a software cursor, with no screen mask.
  1504.      We  use  the macro TC(),  defined in MOUSTRAP.H,  to build a  cursor
  1505.      which  is  just a space,  with a red foreground (color 4) on  a  red
  1506.      background.
  1507.  
  1508.              Add_Mouse_Button(0,M_Middle,'2');
  1509.  
  1510.      For  our first button definition,  we'll say that anytime the Middle
  1511.      button  is pressed,  Read_Mouse will return an ASCII character  '2',
  1512.      regardless  of  what page is active (provided at least one  page  IS
  1513.      active).
  1514.  
  1515.              Add_Mouse_Button(z,M_Left,'1');
  1516.  
  1517.      Next  we'll  have  pressing  the Left button  return  an  ASCII  '1'
  1518.      whenever page Z is active.
  1519.  
  1520.                                 - Page 25 -
  1521.  
  1522.  
  1523.  
  1524.                                                             MouseTrap Library
  1525.                                                            September 21, 1988
  1526.  
  1527.  
  1528.              Add_Mouse_Button(z,M_Right,0);
  1529.              Add_Mouse_Hot_Spot(z,M_Right,7,13,13,18,'C');
  1530.  
  1531.      Now,  we  add our first Hot Spot.  Here,  we must first declare  the
  1532.      Right  button in Page Z,  then we declare the area in the  rectangle
  1533.      (7,13) - (13,18) as a hot spot returning the character 'C' when that
  1534.      button  is pressed while page Z is active.   Since no other hot spot
  1535.      is defined,  clicking the right button outside that area will return
  1536.      0, just as if no click had occurred.
  1537.  
  1538.              Add_Mouse_Button(y,M_Left,0);
  1539.  
  1540.              Add_Mouse_Hot_Spot(y,M_Left,15,20,24,30,'L');
  1541.              Add_Mouse_Hot_Spot(y,M_Left,15,30,24,40,'R');
  1542.  
  1543.      Continuing  in  a similar vein,  we define two hot spots in page  Y.
  1544.      When  the Left button is pressed,  if the cursor is in the left side
  1545.      we'll  get  the  character  'L',  while the right  side  return  the
  1546.      character 'R'
  1547.  
  1548.      do {
  1549.  
  1550.              Activate_Mouse_Page(z);
  1551.  
  1552.      As  we  enter the loop,  we activate page Z.   The mouse  cursor  is
  1553.      "turned on" with it's movement limited to the edges of the page.
  1554.  
  1555.              c=Get_Char_Mouse_Kbd();
  1556.              printf("Page Z: Character \"%c\"",c);
  1557.  
  1558.      We stop,  and get a character from either the keyboard (which is not
  1559.      much fun), or via the mouse; and print it.
  1560.  
  1561.              Activate_Mouse_Page(y);
  1562.              c=Get_Char_Mouse_Kbd();
  1563.              printf("Page Y: Character \"%c\"",c);
  1564.  
  1565.      Now,  we  activate page Y (which automatically deactivates page  Z).
  1566.      The mouse cursor moves into the new area, and it's motion is limited
  1567.      to that range.  We get another character and print it.
  1568.  
  1569.  
  1570.              } while (c!='2');
  1571.  
  1572.              Clear_All_Mouse_Definitions();
  1573.  
  1574.              Define_Mouse_System(M_Overlaid_Pages);
  1575.  
  1576.      Now, we want to start over,  so we clear all of the old definitions,
  1577.      and restart, but this time using overlaid pages.
  1578.  
  1579.  
  1580.  
  1581.                                 - Page 26 -
  1582.  
  1583.  
  1584.  
  1585.                                                             MouseTrap Library
  1586.                                                            September 21, 1988
  1587.  
  1588.              y=Add_Mouse_Page(M_Text_Coord,15,20,24,40);
  1589.              z=Add_Mouse_Page(M_Text_Coord,5,10,15,20);
  1590.              Add_Mouse_Button(0,M_Middle,'2');
  1591.              Add_Mouse_Button(z,M_Left,'1');
  1592.              Add_Mouse_Button(z,M_Right,0);
  1593.              Add_Mouse_Hot_Spot(z,M_Right,7,13,13,18,'C');
  1594.              Add_Mouse_Button(y,M_Left,0);
  1595.              Add_Mouse_Hot_Spot(y,M_Left,15,20,24,30,'L');
  1596.              Add_Mouse_Hot_Spot(y,M_Left,15,30,24,40,'R');
  1597.  
  1598.              Set_Mouse_Text_Cursor(0,0,TC('+',4,2));
  1599.  
  1600.      We'll redefine all of our pages, buttons, and hot spots,  exactly as
  1601.      we  did the first time.   We'll also change the mouse  cursor,  this
  1602.      time  to something a bit more exciting than before,  a red plus sign
  1603.      on a green background (color 2).
  1604.  
  1605.      do {
  1606.              Activate_Mouse_Page(z);
  1607.              c=Get_Char_Mouse_Kbd();
  1608.              printf("Page Z: Character \"%c\"",c);
  1609.  
  1610.      Again, we activate page Z, and get a character from it.   This works
  1611.      exactly as it did in  the first loop using single page mode.
  1612.  
  1613.              DeActivate_Mouse_Page(z);
  1614.              Activate_Mouse_Page(y);
  1615.              c=Get_Char_Mouse_Kbd();
  1616.              printf("Page Y: Character \"%c\"",c);
  1617.  
  1618.      And  again,  we activate page Y,  and get a character from it.   The
  1619.      only difference is that we had to first deactivate page Z.
  1620.  
  1621.              Activate_Mouse_Page(z);
  1622.              c=Get_Char_Mouse_Kbd();
  1623.              printf("Page Y & Z: Character \"%c\"",c);
  1624.  
  1625.      Now we get flashy.  Without deactivate page Y, we'll reactivate page
  1626.      Z.  You will notice that the mouse can now move within a much larger
  1627.      area,  specifically  the  rectangle which circumscribes both of  the
  1628.      smaller rectangle.   Notice that if you click the left button in the
  1629.      area that is not within the boundaries of either page,  "1"  will be
  1630.      return.   This  is because the button definition says to return  "1"
  1631.      whenever page Z is active,  regardless of where the cursor is,  even
  1632.      if  it is outside the stated area of Page Z.   However,  notice that
  1633.      the  Hot  Spots of the left button in page Y,  take precedence  over
  1634.      this.   This  is  because the BUTTON definition on page Y  was  give
  1635.      after the button definition off page Z, and therefore overrules it.
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.                                 - Page 27 -
  1643.  
  1644.  
  1645.  
  1646.                                                             MouseTrap Library
  1647.                                                            September 21, 1988
  1648.  
  1649.              DeActivate_Mouse_Page(y);
  1650.  
  1651.      Now,  we deactivate page Y,  leaving only page Z.   Notice that this
  1652.      does not restrict the mouse's movements, which can still more around
  1653.      the area of both pages.   The only way the shirk the window again is
  1654.      by  executing  the  Clear_Mouse_Pages()  function.   (Executing  the
  1655.      Clear_All_Mouse_Definitions  function would also to the  trick,  but
  1656.      that's  a little more dramatic than we'd like at this  point)   This
  1657.      problem should be fixed in the next release.
  1658.  
  1659.              }
  1660.      }
  1661.  
  1662.  
  1663.      You  should  also  remember  that,  although we  always  used  ASCII
  1664.      characters  for  return  values in the example,   ANY  character  or
  1665.      integer value, in the range of 1 to 65534, can be used.
  1666.  
  1667.  
  1668.  
  1669.  
  1670.  
  1671.  
  1672.  
  1673.  
  1674.  
  1675.  
  1676.  
  1677.  
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.                                 - Page 28 -
  1704.  
  1705.  
  1706.  
  1707.                                                             MouseTrap Library
  1708.                                                            September 21, 1988
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.              Chapter 5
  1716.  
  1717.                              Technical Specification
  1718.  
  1719.  
  1720.  
  1721.  
  1722.              This  chapter  is  provided only to those who have  paid  to
  1723.      become  registered  uses.   This was done because I assumed that  it
  1724.      would  be  of little use to anyone who didn't have the  source  code
  1725.      (which  also comes with registration).   This method also gives me a
  1726.      few extra weeks to write it.
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740.  
  1741.  
  1742.  
  1743.  
  1744.  
  1745.  
  1746.  
  1747.  
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.                                 - Page 29 -
  1765.  
  1766.  
  1767.  
  1768.                                                             MouseTrap Library
  1769.                                                            September 21, 1988
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.              Chapter 6
  1778.  
  1779.                              Appendix
  1780.  
  1781.  
  1782.  
  1783.                      A.      MOUSTRAP.H
  1784.                      B.      Global Variables
  1785.                      C.      Error Codes
  1786.                      D.      Reference
  1787.                      E.      Support
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803.  
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809.  
  1810.  
  1811.  
  1812.  
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.                                 - Page 30 -
  1826.  
  1827.  
  1828.  
  1829.                                                             MouseTrap Library
  1830.                                                            September 21, 1988
  1831.  
  1832.  
  1833.              Appendix A  :   MOUSTRAP.H
  1834.  
  1835.  
  1836.              The  header file,  MOUSTRAP.H should be included in every  C
  1837.      program  which  uses the MouseTrap Library functions.   It  includes
  1838.      complete  function  prototypes  for each of  the  MouseTrap  Library
  1839.      functions.  In addition,  it defines a number of constants which are
  1840.      to be used with the functions.  These include:
  1841.  
  1842.              M_Overlaid_Pages    -and-    M_Single_Pages,  which are used
  1843.      with the function Define_Mouse_System.
  1844.  
  1845.              M_Text_Coord -and- M_Graphic_Coord,  which are used with the
  1846.      Add_Mouse_Page function, to tell which system screen coordinates are
  1847.      being given in.
  1848.  
  1849.              M_Left, M_Right, M_Center, -and- M_Middle, which are used to
  1850.      refer  to the mouse buttons whenever necessary.   Note that M_Center
  1851.      and  M_Middle are equivalent,  and you may use whichever holds  your
  1852.      fancy.
  1853.  
  1854.              M_HORIZ -and- M_VERT, which are used with Set_Mouse_Limits.
  1855.  
  1856.              MERROR -and- MNOERROR, (-1 and 0,  respectively),  which are
  1857.      return  by  various  functions to indicate whether or not  an  error
  1858.      occurred.  Also defined are a large number of error codes, which are
  1859.      discussed further in appendix C.
  1860.  
  1861.              The  macro  TC()  is used to create an integer value in  the
  1862.      form BFCC, where B is the background color, F, the foreground color,
  1863.      and CC is a character.  This value is used by Set_Mouse_Text_Cursor,
  1864.      (and  by  other  routines  outside of the  MouseTrap  Library  which
  1865.      perform  direct screen writes).   The macro require that you give it
  1866.      the character,  foreground and background color code.  The statement
  1867.      TC('A',14,5) would produce the code 5E41h, which mean the letter 'A'
  1868.      in bright Yellow on a Magenta background.
  1869.  
  1870.              It also declared three global variables, which are described
  1871.      in Appendix B.
  1872.  
  1873.              Also  defined  is the data type "mouse_t"  which is used  to
  1874.      define  vitually  every  variable used in the  MouseTrap  functions.
  1875.      Also included are the structures definitions for Pages, buttons, and
  1876.      hot spots.  I'll not should what you can use them for, but I thought
  1877.      you might be interested.
  1878.  
  1879.              The  last  group of lines will "force"  LINK to include  the
  1880.      proper  version of the MouseTrap library,  without being  explicitly
  1881.      told  to.    This  will  only  work with  Microsoft  C  5.1.   Other
  1882.      compliers will probable generate a warning for these lines.
  1883.  
  1884.  
  1885.  
  1886.                                 - Page 31 -
  1887.  
  1888.  
  1889.  
  1890.                                                             MouseTrap Library
  1891.                                                            September 21, 1988
  1892.  
  1893.  
  1894.              Appendix B  :   Global Variables
  1895.  
  1896.  
  1897.              There  are  three global variables used with  the  MouseTrap
  1898.      Function.  They are:
  1899.  
  1900.              _mouse_there:   This  is initialized to 0,  meaning no mouse
  1901.      available,   and   is   set   by  calling  either   Check_Mouse   or
  1902.      Define_Mouse_System.   After  a call to either of those functions it
  1903.      is  set  to either 0,  meaning that there is STILL no mouse on  this
  1904.      system, or, 2 or 3, giving the number of buttons on the mouse. Since
  1905.      "no mouse" is zero,  and "mouse present"  is nonzero,  this variable
  1906.      can also be used as a TRUE/FALSE value.
  1907.  
  1908.              M_Paging_Method  :  This  simply holding the value you  used
  1909.      with   Define_Mouse_System,   and  is  either  M_Overlaid_Pages   or
  1910.      M_Single_Pages.
  1911.  
  1912.              M_Error  :  This holds the error code of the last error that
  1913.      occurred.    Full  description  of  the  error  codes  is  given  in
  1914.      Appendix C.
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.  
  1921.  
  1922.  
  1923.  
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.                                 - Page 32 -
  1948.  
  1949.  
  1950.  
  1951.                                                             MouseTrap Library
  1952.                                                            September 21, 1988
  1953.  
  1954.  
  1955.              Appendix C   :  Error Codes.
  1956.  
  1957.              Error  conditions are indicated by a function returning  the
  1958.      value  MERROR (-1)  with the error code given in the global variable
  1959.      M_Error.   The  error  code remains in M_Error until either  cleared
  1960.      manually by the user or altered by another error.
  1961.  
  1962.              The error code are:
  1963.  
  1964.      MNOINIT         An  attempt  was  made to use one  of  the  advanced
  1965.                      functions without first calling Define_Mouse_System
  1966.  
  1967.      MNOMOUSE        An attempt was made to use a function while no mouse
  1968.                      was attached to the system.
  1969.  
  1970.      MNOSPACE        An attempt to add a new Page,  Button,  or hot  spot
  1971.                      failed  because there was not enough available  RAM.
  1972.                      Since  these definitions use so little memory,  this
  1973.                      error should rarely occur.
  1974.  
  1975.      MTOOMANY        An attempt was made to define more than 16 pages  in
  1976.                      Overlaid  mode,  or more than 65536 pages in  single
  1977.                      page  mode,  or more than 65536 hot spots (in either
  1978.                      mode).  Remember,  that all hot spots defined,  even
  1979.                      those  later  deleted,  count  towards  this  limit.
  1980.                      (Deleted pages, however, do not.)
  1981.  
  1982.      MNOREINIT       An  attempt  was made to  call  Define_Mouse_System,
  1983.                      after pages were added. All pages (and buttons,  and
  1984.                      hot  spots)  must be removed before a second call to
  1985.                      Define_Mouse_System may be made.
  1986.                      Use Clear_All_Mouse_Definitions().
  1987.  
  1988.      MNOTPAGE         An  attempt was made to reference a page which  had
  1989.                       not yet been defined.
  1990.  
  1991.      MNOTBUTTON       An attempt was made to reference a button which had
  1992.                       not yet been defined.
  1993.  
  1994.      MNOTHOTSPOT      An  attempt was made to reference a hot spot  which
  1995.                       had not yet been defined.
  1996.  
  1997.      MBUTTONRET       An  attempt was made to tied a hot spot  to  button
  1998.                       which already has it's own return value.
  1999.  
  2000.      MNOACTIVE        An attempt was made to call Read_Mouse with no page
  2001.                       active .
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.                                 - Page 33 -
  2009.  
  2010.  
  2011.  
  2012.                                                             MouseTrap Library
  2013.                                                            September 21, 1988
  2014.  
  2015.  
  2016.              Appendix D  :   Reference
  2017.  
  2018.  
  2019.      Much of the information used to create this manual was taken from:
  2020.  
  2021.      Mouse System Corporation,  GOptimouse Reference Manual,  version 4.0H,
  2022.      Copyright 1984, 1985.
  2023.  
  2024.      Cort, Nigel. "GHow to Handle a Mouse,  part 1H."  The C Gazette.  2:4,
  2025.      March 1988.
  2026.  
  2027.      Cort, Nigel. "GHow to Handle a Mouse,  part 2.H"  The C Gazette.  3:1,
  2028.      Summer 1988
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.                                 - Page 34 -
  2070.  
  2071.  
  2072.  
  2073.                                                             MouseTrap Library
  2074.                                                            September 21, 1988
  2075.  
  2076.  
  2077.              Appendix E   :  Support
  2078.  
  2079.      James  M.  Curran  is the author of the MouseTrap Functions  and  is
  2080.      solely  responsible  for  it's  content.   Any  comments,   problem,
  2081.      suggestions, marriage proposals, or death threats stemming from this
  2082.      library should be directed to him at:
  2083.                              James M. Curran
  2084.                              24 Greendale Road
  2085.                              Cedar Grove, NJ 07009-1313
  2086.  
  2087.      Don't forget the "M."  since the family is just swarming with "James
  2088.      Curran"'s
  2089.  
  2090.      He can also be reached via Compuserve at [72261,655].
  2091.  
  2092.      And  for  the  more  adventurous,  he's also a  regular  on  several
  2093.      northern New Jersey BBS's under the handle "The Perfect Stranger"
  2094.  
  2095.  
  2096.      Special  Note  for  version 1.0:   Due to the painfully  short  time
  2097.      between  the  original  inspiration for this,  and my leaving  on  a
  2098.      European  trip (which,  I assume will do much to help me forget said
  2099.      pain), this entire project was written, debugged,  and documented in
  2100.      10 days (while still working at the day job).  Obviously,  there HAS
  2101.      to be some bugs lurking out there somewhere, if not in the functions
  2102.      themselves,  in  this documentation (there are,  by the  way,  three
  2103.      functions in the library that are not described here).  Any feedback
  2104.      from  users  will be of great assistance in putting out version  1.1
  2105.      when I get back.
  2106.  
  2107.  
  2108.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.                                 - Page 35 -
  2131.  
  2132.  
  2133.          ----------------end-of-author's-documentation---------------
  2134.  
  2135.                         Software Library Information:
  2136.  
  2137.                    This disk copy provided as a service of
  2138.  
  2139.                         The Public (Software) Library
  2140.  
  2141.          We are not the authors of this program, nor are we associated
  2142.          with the author in any way other than as a distributor of the
  2143.          program in accordance with the author's terms of distribution.
  2144.  
  2145.          Please direct shareware payments and specific questions about
  2146.          this program to the author of the program, whose name appears
  2147.          elsewhere in  this documentation. If you have trouble getting
  2148.          in touch with the author,  we will do whatever we can to help
  2149.          you with your questions. All programs have been tested and do
  2150.          run.  To report problems,  please use the form that is in the
  2151.          file PROBLEM.DOC on many of our disks or in other written for-
  2152.          mat with screen printouts, if possible.  The P(s)L cannot de-
  2153.          bug programs over the telephone.
  2154.  
  2155.          Disks in the P(s)L are updated monthly, so if you did not get
  2156.          this disk  directly from the P(s)L,  you should be aware that
  2157.          the files in this set may no  longer be the current versions.
  2158.  
  2159.          For a copy of the latest monthly software library newsletter
  2160.          and a list of the 1,400+ disks in the library, call or write
  2161.  
  2162.                         The Public (Software) Library
  2163.                               P.O.Box 35705 - F
  2164.                            Houston, TX 77235-5705
  2165.                                (713) 665-7017
  2166.  
  2167.